<div class="grid_16">
	<h1 style="text-align: right;"><a style="color: blue;" href="<?php echo Yii::app()->createUrl('tickets/public/logout/agency_id/'.$_GET['agency_id']);?>">Hi, <?php $tmp = Ticket::model()->findByAttributes(array('email' => Yii::app()->session['email']));
	echo  $tmp->name;
	?>!&nbsp Log Out</a> </h1>
	<div id="ps-invoice-index" class="box">
		<h2 class="box_head grad_colour with-icon"><img width="16" height="16" src="/images/icons/fugue/folder.png" />Tickets</h2>
			<?php
			$this->widget('PsGridView', array(
				'id' => 'invoice-index-grid',
				'dataProvider' => $ticket->search(),
				'filter' => $ticket,
				'template' => '{items}{pager}{pagesize}',
				'htmlOptions' => array(
					'class' => 'grid-view grey'
				),
				'pagerCssClass' => 'pager float-right',
				'pagesizeCssClass' => 'pager-pagesize float-right',
				'columns' => array(
					array(
						'header' => 'Date',
						'name' => 'create_time',
						'type' => 'date',
						'htmlOptions' => array('width' => 100),
					),
					array(
						'header' => '#',
						'type' => 'raw',
						'name' => 'ticket_code',
						'value' => 'CHtml::link("#" . $data->ticket_code, array("public/view", "ticket_code" => $data->ticket_code, "email" => $data->email, "agency_id" => $this->grid->controller->agency->id), array("class" => "blue link"))',
						'htmlOptions' => array('width' => 50),
					),
					array(
						'name' => 'subject',
						'type' => 'raw',
						'value' => 'CHtml::link($data->subject, array("public/view", "ticket_code" => $data->ticket_code, "email" => $data->email, "agency_id" => $this->grid->controller->agency->id), array("class" => "blue link"))',
					),
					array(
						'name' => 'current_status',
						'value' => function ($data){
							$status = TicketStatusHistory::model()->findByAttributes(array('ticket_id'=>$data->id),array('order' =>'update_time DESC'));
							echo  $status->ticketStatusType->name;
						},
						'filter' => CHtml::listData(TicketStatusType::model()->findAll(), 'id', 'name'),
						'htmlOptions' => array('width' => 80),
					),
					array(
						'name' => 'ticket_type_id',
							'filter' => CHtml::listData(TicketType::model()->findAllByAttributes(array('agency_id' => $_GET['agency_id'])), 'id', 'name'),
							'value' => function ($data){
								echo TicketType::model()->findByPk($data->ticket_type_id)->name;
							},
							'htmlOptions' => array('width' => 80),
					),
					array(
						'name' => 'ticket_source_id',
						'filter' => CHtml::listData(TicketSource::model()->findAll(), 'id', 'name'),
						'value' => function ($data){
							echo TicketSource::model()->findByPk($data->ticket_source_id)->name;
						},
						'htmlOptions' => array('width' => 80),
					),
					/*
					array(
						'header' => 'From',
						'name' => 'name',
						'htmlOptions' => array('width' => 200),
					), */
				)
			));
			?>
	</div>
</div>

<script type="text/javascript">
	function actionDelete()
	{
		if ($("input:checkbox[name='static-pages-grid_c0[]']:checked").length == 0) {
			alert('<?php echo 'Please select at least one item to remove.'; ?>');
			return false;
		}
		if (confirm('<?php echo 'Are you sure you want to delete?'; ?>')) $('#static-page-form').submit();
		return false;
	}
</script>